local huohua = fk.CreateSkill {
  name = "th_huohua",
  max_phase_use_time = 1,
}

huohua:addEffect("viewas", {
  anim_type = "offensive",
  pattern = "fire__slash",
  mute_card = false,
  prompt = "#th_huohua",
  view_as = function(self, player,cards)
    local card = Fk:cloneCard(self.pattern)
    card.skillName = huohua.name
    return card
  end,
  before_use = function(self, player, use)
    use.extraUse = true
  end,
  after_use = function(self, player, use)
    if not use.damageDealt then
      player.room:setPlayerMark(player, "@@th_huohua", 1)
    end
  end,
  enabled_at_response = Util.FalseFunc,
}, { check_skill_limit = true })

huohua:addEffect(fk.PreCardUse, {
  is_delay_effect = true,
  can_trigger = function(self, event, target, player, data)
    if target == player then
      return data.card and data.card.trueName == "slash" and player:getMark("@@th_huohua") ~= 0
    end
  end,
  on_cost = Util.TrueFunc,
  on_use = function(self, event, target, player, data)
    data.additionalDamage = (data.additionalDamage or 0) + 1
    player.room:setPlayerMark(player, "@@th_huohua", 0)
  end,
})

huohua:addTest(function(room, me)
  local comp2 = room.players[2]
  local jink = room:printCard("jink")

  FkTest.RunAddSkills(me, huohua.name)

  FkTest.runInRoom(function ()
    room:obtainCard(comp2, jink)
  end)
  FkTest.setNextReplies(me, {
    FkTest.replyUseSkill(huohua.name, {comp2}),
    FkTest.replyCard(Fk:getCardById(1), {comp2})
  })
  FkTest.setNextReplies(comp2, {
    FkTest.replyCard(jink)
  })

  --- test: me发动技能，comp2闪
  --- 期望: me发动技能，此【杀】对me无效
  FkTest.runInRoom(function ()
    me:gainAnExtraPhase(Player.Play)
  end)

  lu.assertEquals(comp2.hp, comp2.maxHp - 2)
end)

Fk:loadTranslationTable{
  ["th_huohua"] = "火花",
  [":th_huohua"] = "出牌阶段限一次，你可以视为使用一张不计入次数的火【杀】，若此【杀】未造成伤害，你使用的下一张【杀】伤害+1。",
  ["#th_huohua"] = "火花：视为使用一张不计入次数的火【杀】，若此【杀】未造成伤害，你使用的下一张【杀】伤害+1",

  ["@@th_huohua"] = "火花",
}

return huohua